<!doctype html>

<html>
<head>
  <meta charset="UTF-8">
  <title>iron-list test</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">

  <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
  <script src="../../web-component-tester/browser.js"></script>
  <link rel="import" href="../../test-fixture/test-fixture.html">

  <link rel="import" href="helpers.html">
  <link rel="import" href="../vaadin-grid.html">
  <link rel="import" href="../../polymer/polymer-element.html">
  <link rel="import" href="../../polymer/lib/utils/import-href.html">
</head>
<body>

  <dom-module id="x-grid">
    <template>
      <style>
        :host {
          display: block;
        }
      </style>

      <vaadin-grid id="grid" items="[1]">
        <vaadin-grid-column>
          <template class="header">[[localize('header')]]</template>
          <template>[[item]]</template>
        </vaadin-grid-column>
      </vaadin-grid>
    </template>
  </dom-module>

  <test-fixture id="grid">
    <template>
      <x-grid></x-grid>
    </template>
  </test-fixture>

  <script>
    window.addEventListener('WebComponentsReady', () => {
      if (window.isV2()) {
        describe('app-localize-behavior', () => {
          let container, column, grid;

          before(done => {
            Polymer.importHref('../../app-localize-behavior/app-localize-behavior.html', () => {
              class XGrid extends Polymer.mixinBehaviors([Polymer.AppLocalizeBehavior], Polymer.Element) {
                static get is() {
                  return 'x-grid';
                }
                static get properties() {
                  return {
                    language: {
                      value: 'en'
                    }
                  };
                }
                ready() {
                  super.ready();
                  this.loadResources('locales.json');
                }
              }
              window.customElements.define(XGrid.is, XGrid);
              done();
            });
          });

          beforeEach(function(done) {
            container = fixture('grid');
            grid = container.$.grid;
            listenOnce(container, 'app-localize-resources-loaded', () => done());
          });

          it('should localize', () => {
            expect(getHeaderCellContent(grid, 0, 0).innerText).to.equal('header');
          });

        });
      }
    });

  </script>

</body>
</html>
